home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TextEditorUtils.h
-
- Contains: TextEditor utility functions & classes
-
- Written by: Steve Smith
-
- Copyright: © 1994 - 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- #ifndef _TEXTEDITORUTILS_
- #define _TEXTEDITORUTILS_
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _EXCEPT_
- // Exceptions define several important macros (ie. CHECKENV)
- // which are used in the SOM method dispatch glue. If Except.h
- // is not included early enough, exceptions may not be thrown
- // correctly when returning from a SOM method with "ev" parameter set.
- #include <Except.h>
- #endif
-
- // -- TextEditor Includes --
-
- #ifndef _SAMPLECOLLECTIONS_
- #include "SampleCollections.h"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _ITEXT_
- #include <IText.h>
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef _ODDEBUG_
- #include <ODDebug.h>
- #endif
-
- #ifndef _TEMPOBJ_
- #include <TempObj.h>
- #endif
-
- // -- Macintosh Includes --
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- // -- Textension Includes --
-
- #ifndef _TextensionCommon_
- #include "TextensionCommon.h"
- #endif
-
- // -- Forward Declarations --
- class ODDraft;
- class ODFacet;
- class ODWindow;
- class ODStorageUnitView;
-
- class CTextension;
- class SampleCode_TextEditor;
-
- //------------------------------------------------------------------------------
- // Typedefs
- //------------------------------------------------------------------------------
-
- struct ScrollDataRec {
- ControlHandle vScrollbar;
- ControlHandle hScrollbar;
- ODFrame* frame;
- CTextension* textension;
- SampleCode_TextEditor* textEditor;
- };
-
- struct FINF {
- short font;
- short face;
- short size;
- };
-
- typedef struct FINF *FINFPtr;
-
- //------------------------------------------------------------------------------
- // Function Prototypes
- //------------------------------------------------------------------------------
-
- ODIText* GetPartName(Environment* ev, ODPart* part, ODType category);
- ODBoolean NamesAreEquivalent(Environment* ev, ODIText* fileName,
- ODIText* partName);
- void GetEditorScriptLanguage(Environment* ev, ODScriptCode* script,
- ODLangCode* language);
-
- void LoadIcons(Environment* ev, ODUShort whichSuite, Handle* suite);
- void LoadThumbnail(Environment* ev, Handle* thumbnail);
-
- Rect TilePartWindow(Environment* ev, Rect* facetBounds,
- Rect* partWindowBounds);
-
- ODUShort CountFacets(Environment* ev, ODFrame* frame);
-
- void TranslateData(Environment* ev, ODStorageUnit* fromSU, ODStorageUnit* toSU,
- ODType translateKind, ODType desiredKind);
-
- FINF GetIndFINF(short id, short num);
- void SetDialogDefaults(DialogPtr dialog, ODUShort finfID, ODUShort index);
-
- void FixedToIntRect(ODRect& fixedRect, Rect& intRect);
- void IntToFixedRect(Rect& intRect, ODRect& fixedRect);
- void LongToFixedRect(TLongRect& longRect, ODRect& fixedRect);
-
- void SetMenuCommandIndString(Environment* ev, ODCommandID command,
- ODSShort resID, ODSShort index);
-
- ODUShort ConvertNumStrToPixels(Str255 value);
- void ConvertPixelsToNumStr(ODUShort value, Str255* numStr);
-
- extern pascal void ScrollProc(ControlHandle control, short partCode);
- extern void ClickLoopProc(unsigned short message, void* data, void* refcon);
-
- ODBoolean KeyCausesModification(EventRecord* event);
- extern pascal ODBoolean OtherDialogFilter(DialogPtr dialog, EventRecord* event,
- short* itemHit);
-
- //=========================================================================
- // Utility Class Definitions
- //=========================================================================
-
- //-------------------------------------------------------------------------
- // CFrameProxy
- //-------------------------------------------------------------------------
- class CFrameProxy // (aka CFuton)
- {
- public:
- CFrameProxy();
- ~CFrameProxy();
-
- void InitFrameProxy(ODID frameID, ODDraft* draft);
- void InitFrameProxy(Environment* ev, ODFrame* frame);
- void Purge(Environment* ev);
-
- ODFrame* GetFrame(Environment* ev);
- void SetFrame(Environment* ev, ODFrame* frame);
- ODBoolean FrameIsLoaded(Environment* ev);
- ODID GetID();
- ODDraft* GetDraft();
-
- private:
- ODFrame* fFrame;
- ODDraft* fDraft;
- ODID fID;
- };
-
- //-------------------------------------------------------------------------
- // CFrameInfo
- //-------------------------------------------------------------------------
- class CFrameInfo
- {
- public:
- CFrameInfo(ODSession* session);
- ~CFrameInfo();
-
- void Externalize(Environment* ev, ODStorageUnitView* storageUnitView);
- void CleanseFrameInfoProperty(Environment* ev, ODStorageUnit* storageUnit);
- void ExternalizeFrameInfo(Environment* ev, ODStorageUnit* storageUnit,
- ODDraftKey key, ODFrame* scopeFrame);
- void CloneInto(Environment *ev, ODDraftKey key,
- ODStorageUnitView* storageUnitView,
- ODFrame* scopeFrame);
- void InitFromStorage(Environment* ev, ODStorageUnitView* storageUnitView);
-
- ODBoolean IsFrameActive();
- void SetFrameActive(ODBoolean active);
- ODBoolean FrameNeedsReactivating();
- void SetFrameReactivate(ODBoolean reactivate);
- ODFacet* GetActiveFacet();
- void SetActiveFacet(ODFacet* facet);
- void SetSourceFrame(Environment* ev, ODFrame* frame);
- ODFrame* GetSourceFrame(Environment* ev);
- void ReleaseSourceFrame(Environment* ev);
- ODBoolean HasSourceFrame();
- ODWindow* AcquirePartWindow(Environment* ev);
- void SetPartWindow(Environment* ev, ODWindow* window);
- void SetDependentFrame(Environment* ev, ODFrame* frame);
- ODFrame* GetDependentFrame(Environment* ev);
- ODBoolean HasDependentFrame();
- void ReleaseDependentFrame(Environment* ev);
- void SetShouldDisposeWindow(ODBoolean should);
- ODBoolean ShouldDisposeWindow();
-
- private:
- CFrameInfo(); /* don't want parts to call */
-
- ODSession* fSession;
- ODFacet* fActiveFacet;
- CFrameProxy* fSourceFrame;
- CFrameProxy* fDependentFrame;
- ODID fPartWindowID;
- ODBoolean fFrameActive;
- ODBoolean fFrameReactivate;
- ODBoolean fShouldDisposeWindow;
- };
-
- //=========================================================================
- // Inline methods
- //=========================================================================
-
- //-------------------------------------------------------------------------
- // CFrameProxy
- //-------------------------------------------------------------------------
-
- inline CFrameProxy::CFrameProxy()
- {
- fFrame = kODNULL;
- fID = kODNULLID;
- fDraft = kODNULL;
- }
-
- inline CFrameProxy::~CFrameProxy()
- {
- ODSafeReleaseObject(fFrame);
- }
-
- inline void CFrameProxy::InitFrameProxy(ODID frameID, ODDraft* draft)
- {
- ASSERT(draft!=kODNULL, kODErrIllegalNullInput);
-
- fFrame = kODNULL;
- fID = frameID;
- fDraft = draft;
- }
-
- inline void CFrameProxy::InitFrameProxy(Environment* ev, ODFrame* frame)
- {
- ASSERT(frame!=kODNULL, kODErrIllegalNullFrameInput);
-
- this->SetFrame(ev,frame);
- }
-
- inline ODID CFrameProxy::GetID()
- {
- return fID;
- }
-
- inline ODDraft* CFrameProxy::GetDraft()
- {
- return fDraft;
- }
-
-
- //-------------------------------------------------------------------------
- // CFrameInfo
- //-------------------------------------------------------------------------
-
- inline ODBoolean CFrameInfo::IsFrameActive()
- {
- return fFrameActive;
- }
-
- inline void CFrameInfo::SetFrameActive(ODBoolean active)
- {
- fFrameActive = active;
- }
-
- inline ODBoolean CFrameInfo::FrameNeedsReactivating()
- {
- return fFrameReactivate;
- }
-
- inline void CFrameInfo::SetFrameReactivate(ODBoolean reactivate)
- {
- fFrameReactivate = reactivate;
- }
-
- inline ODFacet* CFrameInfo::GetActiveFacet()
- {
- return fActiveFacet;
- }
-
- inline void CFrameInfo::SetActiveFacet(ODFacet* facet)
- {
- fActiveFacet = facet;
- }
-
- inline ODFrame* CFrameInfo::GetSourceFrame(Environment* ev)
- {
- return (fSourceFrame->GetFrame(ev));
- }
-
- inline ODBoolean CFrameInfo::HasSourceFrame()
- {
- return (fSourceFrame != kODNULL);
- }
-
- inline ODFrame* CFrameInfo::GetDependentFrame(Environment* ev)
- {
- return (fDependentFrame->GetFrame(ev));
- }
-
- inline ODBoolean CFrameInfo::HasDependentFrame()
- {
- return (fDependentFrame != kODNULL);
- }
-
- inline void CFrameInfo::SetShouldDisposeWindow(ODBoolean should)
- {
- fShouldDisposeWindow = should;
- }
-
- inline ODBoolean CFrameInfo::ShouldDisposeWindow()
- {
- return fShouldDisposeWindow;
- }
-
-
- #endif
-
-